package models

import (
	__ "appointment-srv/basic/proto"
	"gorm.io/gorm"
)

type Department struct {
	gorm.Model
	Department   string `gorm:"type:varchar(7);comment:'科室名称'"`
	HospitalId   int    `gorm:"type:int;comment:'医院id'"`
	CategoryId   int    `gorm:"type:int;comment:'分类id'"`
	Status       int    `gorm:"type:int;comment:'0 启用 1 禁用'"`
	Introduction string `gorm:"type:varchar(90);unique;comment:'简介'"`
}
type DepartmentDoctorRel struct {
	DoctorId     int    `gorm:"type:int;comment:'医生id'"`
	DepartmentId int    `gorm:"type:int;comment:'科室id'"`
	IsMain       int    `gorm:"type:int;comment:是否主科室 '0 否 1 是'"`
	Introduction string `gorm:"type:varchar(90);unique;comment:'简介'"`
}
type DepartmentCategory struct {
	Department   string `gorm:"type:varchar(7);comment:'科室名称'"`
	HospitalId   int    `gorm:"type:int;comment:'医院id'"`
	CategoryId   int    `gorm:"type:int;comment:'分类id'"`
	Status       int    `gorm:"type:int;comment:'0 启用 1 禁用'"`
	CategoryName string `gorm:"type:varchar(90);unique;comment:'分类名字'"`
	SortOrder    int    `gorm:"type:int;comment:'分类排序的 启用 1 禁用'"`
}

func (s *Department) GetList(db *gorm.DB) (list []*__.DepartmentList, err error) {
	err = db.Model(&Department{}).Find(&list).Error
	return
}

func (s *Department) CreateDepartment(db *gorm.DB) error {
	err := db.Create(&Department{}).Error
	return err
}
